﻿<CascadingValue Value="@CustomLoginStatus" Name="CustomLoginStatus">
    <CascadingAuthenticationState>
        <Router AppAssembly="typeof(RapidCmsRouter).Assembly">
            <Found Context="routeData">
                <AuthorizeView>
                    <Authorized>
                        <RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
                    </Authorized>
                    <NotAuthorized>
                        <LayoutView Layout="typeof(EmptyLayout)">
                            <LoginPage CustomElement="CustomLoginScreen" />
                        </LayoutView>
                    </NotAuthorized>
                </AuthorizeView>
            </Found>
            <NotFound>
                <AuthorizeView>
                    <Authorized>
                        <LayoutView Layout="typeof(MainLayout)">
                            <div class="content">
                                <p><strong>Page not found</strong></p>
                                <p>Sorry, but there's nothing here!</p>
                            </div>
                        </LayoutView>
                    </Authorized>
                    <NotAuthorized>
                        <LayoutView Layout="typeof(EmptyLayout)">
                            <LoginPage CustomElement="CustomLoginScreen" />
                        </LayoutView>
                    </NotAuthorized>
                </AuthorizeView>
            </NotFound>
        </Router>
    </CascadingAuthenticationState>
</CascadingValue>

@code {
    private RenderFragment? CustomLoginScreen { get; set; }
    private RenderFragment? CustomLoginStatus { get; set; }

    [Inject]
    private ILogin LoginRegistration { get; set; } = default!;

    protected override async Task OnParametersSetAsync()
    {
        CustomLoginScreen = LoginRegistration.CustomLoginScreenRegistration.ToRenderFragment();
        CustomLoginStatus = LoginRegistration.CustomLoginStatusRegistration.ToRenderFragment();

        await base.OnParametersSetAsync();
    }
}
